package org.fast.develop.logicflow.ws.message;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.fast.develop.logicflow.runtime.enums.ExecuteDebugEnum;

/**
 * @author czh
 * @version V1.0
 * @data Created on 2023-01-12 15:33
 */
public class MessageFactory {

    public static Message create(String message){
        JSONObject jsonObject = JSONUtil.parseObj(message);
        ExecuteDebugEnum type = ExecuteDebugEnum.create(jsonObject.get("type"));
        if(ExecuteDebugEnum.start.equals(type)){
            return JSONUtil.toBean(message, StartMessage.class);
        } else {
            return JSONUtil.toBean(message, RunTimeMessage.class);
        }
    }
}
